home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tegl6b.zip / INTROPAK.EXE / lha / TGRAPH.DOC < prev    next >
Text File  |  1991-08-16  |  11KB  |  333 lines

  1. {-----------------------------------------------------------------------------}
  2. {               TEGL Windows ToolKit II                  }
  3. {          Copyright (C) 1990, TEGL Systems Corporation              }
  4. {                All Rights Reserved.                  }
  5. {-----------------------------------------------------------------------------}
  6. {$I Switches.inc}
  7.  
  8. UNIT TGraph;
  9.  
  10. INTERFACE
  11.  
  12. USES Dos,
  13.      teglfont,
  14.      {$IFDEF TEGLDEMO}
  15.      errorlog,
  16.      {$ENDIF}
  17.      videochk;
  18.  
  19. const
  20.   { GraphResult error return codes: }
  21.   grOk             =     0;
  22.   grNoInitGraph      =    -1;
  23.   grNotDetected      =    -2;
  24.   grFileNotFound     =    -3;
  25.   grInvalidDriver    =    -4;
  26.   grNoLoadMem         =    -5;
  27.   grNoScanMem         =    -6;
  28.   grNoFloodMem         =    -7;
  29.   grFontNotFound     =    -8;
  30.   grNoFontMem         =    -9;
  31.   grInvalidMode      = -10;
  32.   grError         = -11;   { generic error }
  33.   grIOerror         = -12;
  34.   grInvalidFont      = -13;
  35.   grInvalidFontNum   = -14;
  36.  
  37.   { define graphics drivers }
  38.   CurrentDriver = -128; { passed to GetModeRange }
  39.   Detect    = 0;    { requests autodetection }
  40.   CGA        = 1;
  41.   MCGA        = 2;
  42.   EGA        = 3;
  43.   EGA64     = 4;
  44.   EGAMono    = 5;
  45.   IBM8514    = 6;
  46.   HercMono    = 7;
  47.   ATT400    = 8;
  48.   VGA        = 9;
  49.   PC3270    = 10;
  50.  
  51.   { graphics modes for each driver }
  52.   CGAC0      = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  53.   CGAC1      = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  54.   CGAC2      = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  55.   CGAC3      = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  56.   CGAHi      = 4;  { 640x200 1 page }
  57.   MCGAC0     = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  58.   MCGAC1     = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  59.   MCGAC2     = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  60.   MCGAC3     = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  61.   MCGAMed    = 4;  { 640x200 1 page }
  62.   MCGAHi     = 5;  { 640x480 1 page }
  63.   EGALo      = 0;  { 640x200 16 color 4 page }
  64.   EGAHi      = 1;  { 640x350 16 color 2 page }
  65.   EGA64Lo    = 0;  { 640x200 16 color 1 page }
  66.   EGA64Hi    = 1;  { 640x350 4 color  1 page }
  67.   EGAMonoHi  = 3;  { 640x350 64K on card, 1 page; 256K on card, 2 page }
  68.   HercMonoHi = 0;  { 720x348 2 page }
  69.   ATT400C0   = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  70.   ATT400C1   = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  71.   ATT400C2   = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  72.   ATT400C3   = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  73.   ATT400Med  = 4;  { 640x200 1 page }
  74.   ATT400Hi   = 5;  { 640x400 1 page }
  75.   VGALo      = 0;  { 640x200 16 color 4 page }
  76.   VGAMed     = 1;  { 640x350 16 color 2 page }
  77.   VGAHi      = 2;  { 640x480 16 color 1 page }
  78.   PC3270Hi   = 0;  { 720x350 1 page }
  79.   IBM8514LO  = 0;  { 640x480 256 colors }
  80.   IBM8514HI  = 1;  { 1024x768 256 colors }
  81.  
  82.   { Colors for SetPalette and SetAllPalette: }
  83.   Black        = 0;
  84.   Blue           = 1;
  85.   Green        = 2;
  86.   Cyan           = 3;
  87.   Red           = 4;
  88.   Magenta      = 5;
  89.   Brown        = 6;
  90.   LightGray    = 7;
  91.   DarkGray     = 8;
  92.   LightBlue    = 9;
  93.   LightGreen   = 10;
  94.   LightCyan    = 11;
  95.   LightRed     = 12;
  96.   LightMagenta = 13;
  97.   Yellow       = 14;
  98.   White        = 15;
  99.  
  100.   { colors for 8514 to set standard EGA colors w/o knowing their values }
  101.   EGABlack           = 0;      { dark colors }
  102.   EGABlue           = 1;
  103.   EGAGreen           = 2;
  104.   EGACyan           = 3;
  105.   EGARed           = 4;
  106.   EGAMagenta           = 5;
  107.   EGABrown           = 20;
  108.   EGALightgray           = 7;
  109.   EGADarkgray           = 56;      { light colors }
  110.   EGALightblue           = 57;
  111.   EGALightgreen        = 58;
  112.   EGALightcyan           = 59;
  113.   EGALightred           = 60;
  114.   EGALightmagenta      = 61;
  115.   EGAYellow           = 62;
  116.   EGAWhite           = 63;
  117.  
  118.   { Line styles and widths for Get/SetLineStyle: }
  119.   SolidLn    = 0;
  120.   DottedLn   = 1;
  121.   CenterLn   = 2;
  122.   DashedLn   = 3;
  123.   UserBitLn  = 4;    { User-defined line style }
  124.  
  125.   NormWidth  = 1;
  126.   ThickWidth = 3;
  127.  
  128.   { Set/GetTextStyle constants: }
  129.   DefaultFont    = 0;    { 8x8 bit mapped font }
  130.   TriplexFont    = 1;    { "Stroked" fonts }
  131.   SmallFont    = 2;
  132.   SansSerifFont = 3;
  133.   GothicFont    = 4;
  134.  
  135.   HorizDir   = 0;    { left to right }
  136.   VertDir    = 1;    { bottom to top }
  137.  
  138.   UserCharSize = 0;    { user-defined char size }
  139.  
  140.   { Clipping constants: }
  141.   ClipOn  = true;
  142.   ClipOff = false;
  143.  
  144.   { Bar3D constants: }
  145.   TopOn  = true;
  146.   TopOff = false;
  147.  
  148.   { Fill patterns for Get/SetFillStyle: }
  149.   EmptyFill      = 0;    { fills area in background color }
  150.   SolidFill      = 1;    { fills area in solid fill color }
  151.   LineFill      = 2;    { --- fill }
  152.   LtSlashFill      = 3;    { /// fill }
  153.   SlashFill      = 4;    { /// fill with thick lines }
  154.   BkSlashFill      = 5;    { \\\ fill with thick lines }
  155.   LtBkSlashFill   = 6;    { \\\ fill }
  156.   HatchFill      = 7;    { light hatch fill }
  157.   XHatchFill      = 8;    { heavy cross hatch fill }
  158.   InterleaveFill  = 9;    { interleaving line fill }
  159.   WideDotFill      = 10; { Widely spaced dot fill }
  160.   CloseDotFill      = 11; { Closely spaced dot fill }
  161.   UserFill      = 12; { user defined fill }
  162.  
  163.   { BitBlt operators for PutImage: }
  164.   NormalPut    = 0;    { MOV }       { left for 1.0 compatibility }
  165.   CopyPut    = 0;    { MOV }
  166.   XORPut    = 1;    { XOR }
  167.   OrPut     = 2;    { OR  }
  168.   AndPut    = 3;    { AND }
  169.   NotPut    = 4;    { NOT }
  170.  
  171.   { Horizontal and vertical justification for SetTextJustify: }
  172.   LeftText   = 0;
  173.   CenterText = 1;
  174.   RightText  = 2;
  175.  
  176.   BottomText = 0;
  177. { CenterText = 1; already defined above }
  178.   TopText    = 2;
  179.  
  180.  
  181. const
  182.   MaxColors = 15;
  183. type
  184.   PaletteType = record
  185.       Size   : byte;
  186.       Colors : array[0..MaxColors] of shortint;
  187.     end;
  188.  
  189.   LineSettingsType = record
  190.       LineStyle : word;
  191.       Pattern    : word;
  192.       Thickness : word;
  193.     end;
  194.  
  195.   TextSettingsType = record
  196.       Font    : word;
  197.       Direction : word;
  198.       CharSize    : word;
  199.       Horiz    : word;
  200.       Vert    : word;
  201.     end;
  202.  
  203.   FillSettingsType = record          { Pre-defined fill style }
  204.       Pattern : word;
  205.       Color   : word;
  206.     end;
  207.  
  208.   FillPatternType = array[1..8] of byte;  { User defined fill style }
  209.  
  210.   PointType = record
  211.       X, Y : integer;
  212.     end;
  213.  
  214.   ViewPortType = record
  215.       x1, y1, x2, y2 : integer;
  216.       Clip         : boolean;
  217.     end;
  218.  
  219.   ArcCoordsType = record
  220.       X, Y         : integer;
  221.       Xstart, Ystart : integer;
  222.       Xend, Yend     : integer;
  223.     end;
  224.  
  225.  
  226. var
  227.   GraphGetMemPtr  : Pointer;   { allows user to steal heap allocation }
  228.   GraphFreeMemPtr : Pointer;   { allows user to steal heap de-allocation }
  229.  
  230. { *** A matching initgraph w/o videoinit *** }
  231. procedure InitMatch(var GraphDriver:integer; var GraphMode:integer; PathToDriver:String);
  232.  
  233. { *** high-level error handling *** }
  234. function  GraphErrorMsg(ErrorCode:integer):String;
  235. function  GraphResult:integer;
  236.  
  237. { *** detection, initialization and crt mode routines *** }
  238. procedure DetectGraph(var GraphDriver,GraphMode:integer);
  239. function  GetDriverName:string;
  240. procedure InitGraph(var GraphDriver:integer;var GraphMode:integer;PathToDriver:String);
  241. function  RegisterBGIfont(Font:pointer):integer;
  242. function  RegisterBGIdriver(Driver:pointer):integer;
  243. function  InstallUserDriver(DriverFileName:string;AutoDetectPtr:pointer):integer;
  244. function  InstallUserFont(FontFileName:string):integer;
  245. procedure SetGraphBufSize(BufSize:word);
  246. function  GetMaxMode:integer;
  247. procedure GetModeRange(GraphDriver:integer;var LoMode,HiMode:integer);
  248. function  GetModeName(GraphMode:integer):string;
  249. procedure SetGraphMode(Mode:integer);
  250. function  GetGraphMode:integer;
  251. procedure GraphDefaults;
  252. procedure RestoreCrtMode;
  253. procedure CloseGraph;
  254. function  GetX:integer;
  255. function  GetY:integer;
  256. function  GetMaxX:integer;
  257. function  GetMaxY:integer;
  258.  
  259. { *** Screen, viewport, page routines *** }
  260. procedure ClearDevice;
  261. procedure SetViewPort(x1,y1,x2,y2:integer;Clip:boolean);
  262. procedure GetViewSettings(var ViewPort:ViewPortType);
  263. procedure ClearViewPort;
  264. procedure SetVisualPage(Page:word);
  265. procedure SetActivePage(Page:word);
  266.  
  267. { *** point-oriented routines *** }
  268. procedure PutPixel(X,Y:integer;Pixel:word);
  269. function  GetPixel(X,Y:integer):word;
  270.  
  271. { *** line-oriented routines *** }
  272. procedure SetWriteMode(WriteMode:integer);
  273. procedure LineTo(X,Y:integer);
  274. procedure LineRel(Dx,Dy:integer);
  275. procedure MoveTo(X,Y:integer);
  276. procedure MoveRel(Dx,Dy:integer);
  277. procedure Line(x1,y1,x2,y2:integer);
  278. procedure GetLineSettings(var LineInfo:LineSettingsType);
  279. procedure SetLineStyle(LineStyle:word;Pattern:word;Thickness:word);
  280.  
  281. { *** polygon, fills and figures *** }
  282. procedure Rectangle(x1,y1,x2,y2:integer);
  283. procedure Bar(x1,y1,x2,y2:integer);
  284. procedure Bar3D(x1,y1,x2,y2:integer;Depth:word;Top:boolean);
  285. procedure DrawPoly(NumPoints:word;var PolyPoints);
  286. procedure FillPoly(NumPoints:word;var PolyPoints);
  287. procedure GetFillSettings(var FillInfo:FillSettingsType);
  288. procedure GetFillPattern(var FillPattern:FillPatternType);
  289. procedure SetFillStyle(Pattern:word;Color:word);
  290. procedure SetFillPattern(Pattern:FillPatternType;Color:word);
  291. procedure FloodFill(X,Y:integer;Border:word);
  292.  
  293. { *** arc, circle, and other curves *** }
  294. procedure Arc(X,Y:integer;StAngle,EndAngle,Radius:word);
  295. procedure GetArcCoords(var ArcCoords:ArcCoordsType);
  296. procedure Circle(X,Y:integer;Radius:word);
  297. procedure Ellipse(X,Y:integer;StAngle,EndAngle:word;XRadius,YRadius:word);
  298. procedure FillEllipse(X,Y:integer;XRadius,YRadius:word);
  299. procedure GetAspectRatio(var Xasp,Yasp:word);
  300. procedure SetAspectRatio(Xasp,Yasp:word);
  301. procedure PieSlice(X,Y:integer;StAngle,EndAngle,Radius:word);
  302. procedure Sector(x,y:Integer;StAngle,EndAngle,XRadius,YRadius:word);
  303.  
  304. { *** color and palette routines *** }
  305. procedure SetBkColor(ColorNum:word);
  306. procedure SetColor(Color:word);
  307. function  GetBkColor:word;
  308. function  GetColor:word;
  309. procedure SetAllPalette(var Palette);
  310. procedure SetPalette(ColorNum:word;Color:shortint);
  311. procedure GetPalette(var Palette:PaletteType);
  312. function  GetPaletteSize:integer;
  313. procedure GetDefaultPalette(var Palette:PaletteType);
  314. function  GetMaxColor:word;
  315. procedure SetRGBPalette(ColorNum,RedValue,GreenValue,BlueValue:integer);
  316.  
  317. { *** bit-image routines *** }
  318. function  ImageSize(x1,y1,x2,y2:integer):word;
  319. procedure GetImage(x1,y1,x2,y2:integer;var BitMap);
  320. procedure PutImage(X,Y:integer;var BitMap;BitBlt:word);
  321.  
  322. { *** text routines *** }
  323. procedure GetTextSettings(var TextInfo:TextSettingsType);
  324. procedure OutText(TextString:string);
  325. procedure OutTextXY(X,Y:integer;TextString:string);
  326. procedure SetTextJustify(Horiz,Vert:word);
  327. procedure SetTextStyle(Font,Direction:word;CharSize:word);
  328. procedure SetUserCharSize(MultX,DivX,MultY,DivY:word);
  329. function  TextHeight(TextString:string):word;
  330. function  TextWidth(TextString:string):word;
  331.  
  332. IMPLEMENTATION
  333.